import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Layout from "@/layout/index.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/login",
    name: "/",
  },
  {
    path: "/login",
    component: () => import("@/views/login/login.vue"),
    name: "login",
  },
  {
    path: "/home",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "/dashboard",
        component: () => import("@/layout/dashboard.vue"),
        name: "dashboard",
        meta: {
          title: "首页",
          icon: "#icondashboard",
        },
      },
    ],
  },
  {
    path: "/system",
    component: Layout,
    name: "system",
    meta: {
      title: "系统管理",
      icon: "setting",
      roles: ["sys:manage"],
    },
    children: [
      {
        path: "/adminUser",
        component: () => import("@/views/system/AdminUser.vue"),
        name: "adminUser",
        meta: {
          title: "管理员管理",
          icon: "UserFilled",
          roles: ["sys:adminUser"],
        },
      },
      {
        path: "/userList",
        component: () => import("@/views/system/UserList.vue"),
        name: "userList",
        meta: {
          title: "用户管理",
          icon: "wallet",
          roles: ["sys:userList"],
        },
      },
      {
        path: "/userAuth",
        component: () => import("@/views/system/UserAuth.vue"),
        name: "userAuth",
        meta: {
          title: "实名认证",
          icon: "UserFilled",
          roles: ["sys:userAuth"],
        },
      },
    ],
  },
  {
    path: "/goodsRoot",
    component: Layout,
    name: "goodsRoot",
    meta: {
      title: "商品管理",
      icon: "setting",
      roles: ["sys:goodsRoot"],
    },
    children: [
      {
        path: "/goodsType",
        component: () => import("@/views/goods/GoodsType.vue"),
        name: "goodsType",
        meta: {
          title: "商品分类",
          icon: "UserFilled",
          roles: ["sys:goodsType"],
        },
      },
      {
        path: "/unusedList",
        component: () => import("@/views/goods/UnusedList.vue"),
        name: "unusedList",
        meta: {
          title: "闲置商品",
          icon: "wallet",
          roles: ["sys:unusedList"],
        },
      },
    ],
  },
  {
    path: "/order",
    component: Layout,
    name: "order",
    meta: {
      title: "订单管理",
      icon: "setting",
      roles: ["sys:order"],
    },
    children: [
      {
        path: "/buyOrder",
        component: () => import("@/views/order/BuyOrder.vue"),
        name: "buyOrder",
        meta: {
          title: "闲置订单",
          icon: "wallet",
          roles: ["sys:buyOrder"],
        },
      },
    ],
  },
  {
    path: "/comment",
    component: Layout,
    name: "comment",
    meta: {
      title: "反馈管理",
      icon: "setting",
      roles: ["sys:comment"],
    },
    children: [
      {
        path: "/commentList",
        component: () => import("@/views/comment/commentList.vue"),
        name: "commentList",
        meta: {
          title: "评论列表",
          icon: "UserFilled",
          roles: ["sys:commentList"],
        },
      },
      {
        path: "/ReportList",
        component: () => import("@/views/comment/ReportList.vue"),
        name: "ReportList",
        meta: {
          title: "反馈列表",
          icon: "UserFilled",
          roles: ["sys:ReportList"],
        },
      },
    ],
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
